home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 3
/
Light ROM 3 - Disc 2.iso
/
programs
/
amiga
/
macromkr
/
rexxscri.lha
/
REXXscripts
/
jpeginfo.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1980-01-07
|
3KB
|
114 lines
/*
* JPEG.rexx
*
* Written by: Ben Williams
* Last Update: March 4th, 1992
* For: Black Belt Systems image processing series IM, IM F/c, and IP.
* ---------------------------------------------------------------------------
* Revision: 1.07
*
* Then BLATENTLY stolen and hacked by me to get JUST the width/height
* of a jpeg file. I hope you guys don't mind.. :-)
*/
parse arg var1
/*
* open rexxsupport.library -- needed for some functions
*/
if ~show('L',"rexxsupport.library") then do
if addlib('rexxsupport.library',0,-30,0) then do
/* everything's ok */
end;
else do
say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
say 'Cannot operate JPEG.rexx without this library - sorry!';
exit 10;
end;
end;
if var1 = '' | var1 = '?' then do
nameid = '';
end;
else do
nameid = right(var1,4);
end;
if nameid ~= '.jpg' | var1 = '' then do
say 'Use: rx jpeg.rexx filename.jpg';
exit(0);
end;
say 'File: 'var1;
jpegfile = var1;
/*
* at this point, we have at least some assurance that we
* have a real JPEG file to work with. Now, we need to look into
* the file and see how big the image is, so we can open a new
* buffer of the appropriate size.
*/
call open(fhandle,jpegfile,'read'); /* open the file */
if rvalue() ~= 65496 then do /* FFD8 */
'message Not a JFIF file! - Initial read fails';
call close(fhandle);
exit(0);
end;
work=1;
do while work = 1
thisid = rvalue();
thisln = rvalue();
thisda = readch(fhandle,thisln-2);
select
when thisid = 65472 | thisid < 65488 then do /* FFC0-FFCF (SOF0-15) */
height = c2d(substr(thisda,2,2));
width = c2d(substr(thisda,4,2));
work=0;
end;
when thisid = 65504 then do /* FFE0 */
fid = left(thisda,4);
if fid ~= 'JFIF' then do
'message Not a JFIF file!';
call close(fhandle);
exit 0;
end;
end;
otherwise do
nop;
end;
end;
end;
call close(fhandle); /* close the file */
if height < 0 then do
"message Bad height: "||height;
exit 0;
end;
if height > 32767 then do
"message Bad height: "||height;
exit 0;
end;
if width < 0 then do
"message Bad width: "||width;
exit 0;
end;
if width > 32767 then do
"message Bad width: "||width;
exit 0;
end;
say 'Width: 'width;
say 'Height: 'height;
exit 0;
end;
rvalue:
wordnum = c2d(readch(fhandle,1)) * 256;
wordnum = wordnum + c2d(readch(fhandle,1));
return wordnum;